<?php
session_start();
error_reporting(1);
/**
 * Created by PhpStorm.
 * User: MrHung
 * Date: 9/23/14
 * Time: 10:10 PM
 */
require_once('../../class_ajax_request/classAjax.php');
include_once('../../application/functions.php');
include_once('../../application/DataConfig.php');
include_once('answer.content.function.php');

$post_id = $_POST['idpost'] ;
$obj              = new AjaxRequest();
$post_meta_array = $obj->get_post_meta($post_id);

foreach($post_meta_array as $post){

    $meta_id = $post['id'];

    $post_type = $post['post_type'];

    $post_question = json_decode( $post['meta_value']);

    $checkArray = $obj->checkAnswered($meta_id,$_SESSION['authenticated'] )    ;

    $extra_value = $post['extra_value'];

    $check = $checkArray[0]['count_check'];
    $chart = '';
    if($check != 0){

        $array_info = get_default_answer($obj, $post_id);


        if($post_type == 1 )
            $chart = binarychart($array_info,$post_id);
        if($post_type == 2 || $post_type == 4 ){
          //  $html_answer = get_slider_answer($obj,$post_id, 'RATING');

            $chart = $obj->renderBarChart($post_id,$post_question,$array_info);
        }
        if($post_type == 3 ){

            $chart = get_slider_answer($obj,$post_id, 'Average',$extra_value,$post_question);

        }
        if($post_type == 4 ){
            $chart = $obj->renderBarChart($post_id,$post_question,$array_info);
        }


    }
    echo $chart;die;
}


